<extend name="Public/content" />
<block name="style">
  <style type="text/css">
    .table>tbody>tr>td{ padding: 4px; vertical-align: middle;}
    body{ background: #fff;}
    .footer {
      width: 100%;
      height: 50px;
      position: fixed;
      bottom: 0;

      left: 0;
      line-height: 50px;
      text-align: right;
      text-align: right;
      border-top: solid 1px #eee;
      padding-right: 10px;
      z-index: 999999999999999;
    }
  </style>
</block>
<block name="body">
  <input type="hidden" name="goods_sn" value="{$goods_sn}" id="goods_sn">
  <include file="Public:artdialog" />
  <div class="row">
    <div class="col-md-12">
      <div class="block-web">

    <h3>填写补货商品数量</h3>
    <hr>
      </div><!--/block-web-->
    </div><!--/col-md-12-->
  </div>

                <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                      <th>商品编号</th>
                      <th>商品数量</th>
                    </tr>
                  </thead>
                  <tbody id="lists">
                <!--       <tr>
                        <td >{$goods_sn}</td>
                        <td ><input type="number" min="0" id="quantity"  size="11" name="quantity"></td>
                      </tr> -->
                  </tbody>
                </table>
           
<!--     <form class="form-horizontal" role="form"   id="card_form" enctype="multipart/form-data">
     <input type="hidden" name="source_order_sn" value="{$source_order_sn}" id="source_order_sn">
      <input type="hidden" name="goods_sn" value="{$goods_sn}" id="goods_sn">
     <div class="form-group center" >
      <div class="col-sm-6" style="margin-left:80px">
        <input type="number" id="idcard" style="width:30%" name="idcard"  placeholder="请填写该商品数量"    class="col-xs-10 col-sm-5">
      </div>
    </div> 
</form> -->

<div class="footer" >
<button class="btn btn-info " type="button" onclick="sub_idcard_img()" >提交</button>
  <button class="btn btn-default bt_close" type="button" onclick="close_dialog()" >关闭</button>
</div>
</block>

<block name="script">

  <script type="text/javascript">
  var goods_sn = "{$goods_sn}";
   $(function(){
    goods_sn = goods_sn.replace("'", '');
    var goods_sn_arr = [];
      goods_sn_arr= goods_sn.split(',');
      var htm = "";
      debugger;
      for(var i=0;i<goods_sn_arr.length;i++){
           htm +='<tr> <td >'+goods_sn_arr[i]+'</td><td ><input type="number" min="0" id="quantity"  size="11" name="quantity"></td></tr>';
      }
      $('#lists').append(htm);
   })
    function close_dialog(){
     art.dialog.open.api.close();return false;
   }


  //提交身份证信息
   function sub_idcard_img(){

    var quantity =  $('#quantity').val();
      if( quantity == ""){
         showvfmsg('0','请先填写数量',2000);return false;
      }
      var data = $('#card_form').serialize();
      var url = "{:U('Replenishment/goods_purchase')}"
      $.ajax({
        url: url,
        type: "post",
        dataType: "json",
        data:{'GoodsSn':goods_sn,'Quantity':quantity },
        success: function (data) {  
            var retstatus = data.RetCode == 1 ? "0" : "1";
            showvfmsg(retstatus, data.Message, 1900);
            if(retstatus == 1){
              setTimeout(function(){art.dialog.open.api.close();return false;},2000) 
              }
        },
         error:function(e){
          console.log('网络错误');
        }
       })
   }
 </script>
</block>
